package reflection_generics_containers.reflection;

/**
 * @author LiuYan
 * @date 2023/7/17
 */
public class SingletonPerson {

    public String name;
    protected Integer age;
    private Byte sex;
    Boolean isMarriage;
    private static volatile SingletonPerson singletonPerson;

    private SingletonPerson() {

    }

    public SingletonPerson(String name, Integer age, Byte sex, Boolean isMarriage) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.isMarriage = isMarriage;
    }

    public static SingletonPerson getSingletonPerson() {
        if (singletonPerson == null) {
            synchronized (SingletonPerson.class) {
                if (singletonPerson == null) {
                    singletonPerson = new SingletonPerson();
                }
            }
        }
        return singletonPerson;

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Byte getSex() {
        return sex;
    }

    public void setSex(Byte sex) {
        this.sex = sex;
    }

    public Boolean getMarriage() {
        return isMarriage;
    }

    public void setMarriage(Boolean marriage) {
        isMarriage = marriage;
    }


    @Override
    public String toString() {
        return "SingletonPerson{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex=" + sex +
                ", isMarriage=" + isMarriage +
                '}';
    }
}
